<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改站点菜单')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-sitemenu-edit" th:object="${databandSitemenu}">
            <input name="id" th:field="*{id}" type="hidden">
<input name="siteid" th:field="*{siteid}" class="form-control" type="hidden" maxlength="30" required>
            <div class="form-group">    
                <label class="col-sm-3 control-label">站点菜单：</label>
                <div class="col-sm-8">
                    <input name="menuname" th:field="*{menuname}" class="form-control" type="text" maxlength="30" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">排序：</label>
                <div class="col-sm-8">
                    <input name="sort" th:field="*{sort}" class="form-control" type="number" required maxlength="10" onkeyup="value=value.replace(/[^\d]/g,'')" onblur="value=value.replace(/[^\d]/g,'')">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">父栏目：</label>
                <div class="col-sm-8">
                    <input name="parentid" th:field="*{parentid}" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">    
                <label class="col-sm-3 control-label">图标：</label>
                <div class="col-sm-8">
                    <input name="icon" th:field="*{icon}" class="form-control" type="text">
                        <div class="ms-parent" style="width: 100%;">
                        <div class="icon-drop animated flipInX" style="display: none;max-height:200px;overflow-y:auto">
                            <div data-th-include="system/menu/icon"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">节点类型：</label>
                <div class="col-sm-8">
                    <select name="nodetype" id="nodetype" th:field="*{nodetype}"  class="form-control m-b">
                        <option value="1">根一级菜单（即第一级）</option>
                        <option value="2">菜单（除根一级菜单以外的菜单）</option>
                        <option value="3">叶子（用于关联报表）</option>
                    </select>
               
                </div>
            </div>
            
            <div class="form-group" id="bindreport">    
                <label class="col-sm-3 control-label">关联报表：</label>
                <div class="col-sm-8">
                    <select name="reportid"  th:field="*{reportid}" id="reportid" class="form-control">
						<option th:each="item:${report}" th:value="${item.id}"
							th:text="${item.title}"></option>
					</select>
                </div>
            </div>
            
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "web/sitemenu";
        $("#form-sitemenu-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-sitemenu-edit').serialize());
            }
        }
        

        $("#bindreport").hide();

        $(function() {
        	
        	$("input[name='icon']").focus(function() {
                $(".icon-drop").show();
            });
        	$("#form-sitemenu-add").click(function(event) {
        	    var obj = event.srcElement || event.target;
        	    if (!$(obj).is("input[name='icon']")) {
        	    	$(".icon-drop").hide();
        	    }
        	});
        	$(".icon-drop").find(".ico-list i").on("click", function() {
        		$('#icon').val($(this).attr('class'));
            });
        });
        
      //监听选中事件
        $('#nodetype').change(function(data){
            //获取选中项的值
            var opt=$("#nodetype").val();
            if (opt == 3){
            	$("#bindreport").show();
            }
            else{
            	$("#bindreport").hide();
            }
        });
    </script>
</body>
</html>